package com.wsseieiei.fireballgame.init;

import com.mojang.datafixers.DSL;
import com.wsseieiei.fireballgame.Main;
import com.wsseieiei.fireballgame.blocks.Backer;
import com.wsseieiei.fireballgame.blocks.Core;
import com.wsseieiei.fireballgame.blocks.Occupyer;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

public class BlockEntityInit {
    public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "fireballgame");
    public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, "fireballgame");
    public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, "fireballgame");
    public static final RegistryObject<Block> MY_MACHINE;
    public static final RegistryObject<BlockEntityType<Backer.MyMachineEntity>> MY_MACHINE_BLOCK_ENTITY;
    public static final RegistryObject<BlockItem> MY_MACHINE_BLOCK_ITEM;

    public static final RegistryObject<Block> OC;
    public static final RegistryObject<BlockEntityType<Occupyer.OcEntity>> OC_BLOCK_ENTITY;
    public static final RegistryObject<BlockItem> OC_BLOCK_ITEM;

    public static final RegistryObject<Block> CORE;
    public static final RegistryObject<BlockEntityType<Core.CoreEntity>> CORE_BLOCK_ENTITY;
    public static final RegistryObject<BlockItem> CORE_BLOCK_ITEM;
    static {
        MY_MACHINE = BLOCKS.register("backer",
                () -> new Backer.MyMachine(BlockBehaviour.Properties.of(Material.METAL)));
        MY_MACHINE_BLOCK_ITEM = ITEMS.register("backer",
                () -> new BlockItem(MY_MACHINE.get(), new Item.Properties().tab(Main.FIREBALL_GAME_TAB)));
        MY_MACHINE_BLOCK_ENTITY = BLOCK_ENTITY_TYPES.register("backer",
                () -> BlockEntityType.Builder.of(Backer.MyMachineEntity::new, MY_MACHINE.get()).build(DSL.remainderType()));

        OC = BLOCKS.register("occupyer",
                () -> new Occupyer.Oc(BlockBehaviour.Properties.of(Material.METAL)));
        OC_BLOCK_ITEM = ITEMS.register("occupyer",
                () -> new BlockItem(OC.get(), new Item.Properties().tab(Main.FIREBALL_GAME_TAB)));
        OC_BLOCK_ENTITY = BLOCK_ENTITY_TYPES.register("occupyer",
                () -> BlockEntityType.Builder.of(Occupyer.OcEntity::new, OC.get()).build(DSL.remainderType()));

        CORE = BLOCKS.register("core",
                () -> new Core.CoreB(BlockBehaviour.Properties.of(Material.METAL).lightLevel(value -> 15).noOcclusion()));
        CORE_BLOCK_ITEM = ITEMS.register("core",
                () -> new BlockItem(CORE.get(), new Item.Properties().tab(Main.FIREBALL_GAME_TAB)));
        CORE_BLOCK_ENTITY = BLOCK_ENTITY_TYPES.register("core",
                () -> BlockEntityType.Builder.of(Core.CoreEntity::new, CORE.get()).build(DSL.remainderType()));
    }
}
